<?php

    require_once(dirname(__FILE__) . '/../includes/common.inc.php');

    $page = Pages::CreatePage( $pageInfo->id );

    $filters = (array)Request::GetParam('filter');
    if ( !isset( $filters['language'] ) )
    {
        $filters['language'] = SiteLanguage::EN;
    }
    $languageSelected = $filters['language'];
    
    $categories = ArticleCategoryTable::GetCategories( $languageSelected );
    $items = array();
    foreach( $categories as $category )
    {
        $items[] = array
        (
            'id'             => $category->GetCategoryId(),
            'name'           => $category->GetName(),
            'language'       => SiteLanguage::GetLanguageName( $category->GetLanguage() ),
            'articles_count' => ArticleTable::GetCountByCategoryId( $category->GetCategoryId() )
        );
    }
    $page->SetVar('language', $languageSelected);
    $page->SetArrVar('languages', CodeDriveSiteLanguage::GetSupportedLanguages());
    $page->SetArrVar('categories', $items);
    $page->Display();

?>